/**
 * THIS OBJECT IS MEANT TO BE THE 'SERVER SIDE' OF THE CLIENT
 * IN OTHER WORDS, IT IS SUPPOSED TO RECEIVE INVOCATIONS FROM THE RMI SERVER
 * So it behaves as a REMOTE OBSERVER
 * TO BE COMPLETED BY THE STUDENTS
 */
package RMIClient;


import util.observer.rmi.RemoteObserver;
import raceReservationServer.IReservationRaceServer; 
import java.rmi.RemoteException;
import raceReservationServer.RaceRMIDTO;

public class RaceRemoteObserver extends RemoteObserver {
	private static final long serialVersionUID = 1L;
	private RaceController rController;
	private IReservationRaceServer server;
	/**
	 * Creates a new instance of RemoteObserver ADD AS MUCH INFORMATION AS
	 * NEEDED
	 */

	public RaceRemoteObserver(RaceController rc, IReservationRaceServer iServer) throws RemoteException {
		rController= rc;
		server=iServer;
		server.addRemoteObserver(this);
	}

	public void stop() {
		try {
			server.deleteRemoteObserver(this);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void update(Object arg) throws java.rmi.RemoteException {
		if (arg instanceof RaceRMIDTO){
			RaceRMIDTO aux= (RaceRMIDTO)arg;
			rController.updateRace(aux);
		}	
	}
}
